package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;

import java.util.Map;

@Component
@Handler(code = "103001",name="问题反馈")
public class FeedBackHandler extends AbstractMessageHandler {

    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception{
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        String serialNo = requestMessage.getArgsPropertyStringValue("serialNo");
        String hospitalCode = requestMessage.getArgsPropertyStringValue("hospitalCode");
        String username = requestMessage.getArgsPropertyStringValue("username");
        String feedContent = requestMessage.getArgsPropertyStringValue("feedContent");
        String feedDate = requestMessage.getArgsPropertyStringValue("feedDate");
        String state = requestMessage.getArgsPropertyStringValue("state");
        Assert.notNull(serialNo, "serialNo 不可为空！");
        Assert.notNull(username, "username 不可为空！");
        Assert.notNull(feedContent, "feedContent 不可为空！");
        IPersonAgent agent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String,Object> res = agent.feedBack(serialNo,hospitalCode,username,feedContent,feedDate,state);
        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage,res);
        return responseMessage;
    }
}